//
//  EmoticonViewCell.swift
//  表情键盘
//
//  Created by lujun on 2021/11/24.
//

import UIKit

class EmoticonViewCell: UICollectionViewCell {
    private lazy var emoticonBtn: UIButton = UIButton()
    var emoticon: Emoticon? {
        didSet {
            guard let emoticon = emoticon else {
                return
            }
            emoticonBtn.setImage(UIImage(contentsOfFile: emoticon.pngPath ?? ""), for: .normal)
            emoticonBtn.setTitle(emoticon.emojiCode, for: .normal)
            
            if emoticon.isRemove {
                emoticonBtn.setImage(UIImage(named: "compose_emotion_delete"), for: .normal)
            }
            
        }
    }
    override init(frame: CGRect) {
        super.init(frame: frame)
        setupUI()
    }
    
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    
}

extension EmoticonViewCell {
    private func setupUI(){
        contentView.addSubview(emoticonBtn)
        emoticonBtn.frame = contentView.bounds
        emoticonBtn.titleLabel?.font = UIFont.systemFont(ofSize: 32)
        emoticonBtn.isUserInteractionEnabled = false
    }
}
